package com.gilight.base.dao;

import com.gilight.base.model.SysPermission;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface SysPermissionMapper {
    int deleteByPrimaryKey(Long id);

    int insert(SysPermission record);

    int insertSelective(SysPermission record);

    SysPermission selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(SysPermission record);

    int updateByPrimaryKey(SysPermission record);

    List<SysPermission> selectByRoleId(Long roleId);

    List<SysPermission> selectByUserId(Long userId);

    List<Map<String,Object>> loadMenuByUserId(@Param(value = "userId") Long userId, @Param(value = "parentId") Long parentId);

    List<SysPermission> selectByParentId(Long parentId);
    List<SysPermission> selectButtonByParentId(@Param(value = "parentId") Long parentId, @Param(value = "type") Integer type);
    List<SysPermission> selectPermissionButtonByRoute(String route);
    List<Long> getUserDefaultRoleByUserId(Long userId);

    List<Map<String, Object>> loadMenuByUserId2(@Param("userId") Long userId, @Param("parentId") Long parentId,@Param("defaultRoleId") Long defaultRoleId,@Param("appKey") String appKey);

    List<Map<String,Object>> selectButtonByParentIdandRoleId(@Param(value = "parentId") Long parentId,@Param(value = "roleId") Long roleId, @Param(value = "type") Integer type);

    void updateUserDefaultRole(@Param("userId") Long userId,@Param("roleId") Long roleId);
    /**
     * 根据菜单route获取菜单信息
     * @param route 菜单route
     * @return
     */
    SysPermission selectByRoute(String route);
    /**
     * 根据用户名、菜单ID获取该用户分配的菜单的数据规则ID
     * @param userCode 用户账号
     * @param permissionId 菜单ID
     * @return
     */
    String queryUserDataRuleIds(@Param(value = "userId") String userId,@Param(value = "permissionId") int permissionId);
}